package com.zsc.newbuds.mapper;

import com.zsc.newbuds.entity.SaleRecord;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author D
 */
public interface SaleRecordMapper {

    /**
     * 增加出售记录
     * @param saleRecord
     */
    @Options(useGeneratedKeys = true, keyProperty = "saleId")
    @Insert("insert into saleRecord(sale_weight,names,sale_money,sell,recordId) values(#{saleWeight},#{names},#{saleMoney},#{sell},#{recordId})")
    void addSaleRecord(SaleRecord saleRecord);

    /**
     * 获取所有出售记录
     * @return
     */
    @Select("select * from saleRecord")
    List<SaleRecord> getSaleRecordList();


    /**
     * 根据ID获取出售记录
     * @param id
     * @return
     */
    @Select("select * from saleRecord where sale_id = #{id}")
    SaleRecord getSaleRecordById(Integer id);
}
